
*libname TP_Data "The location of the data folder\TP_Pseudo";



/*Run this Macro to report Daniel, Grinblatt, Titman, and Wermers (1997) (DGTW) characteristic-adjusted mean returns and the Three- to Seven-factor model alphas*/

%MACRO DGTW_Ret_and_Alphas(Dataset=, DGTW_Ret_Var=, Ex_Ret_Var=);

Data Return_Data;
set &Dataset;
run;

proc means data= Return_Data mean stderr t prt ;
var  &DGTW_Ret_Var;
run;

proc reg data= Return_Data plots=none;
model &Ex_Ret_Var =MKTRF SMB HML;
run;

proc reg data= Return_Data plots=none;
model &Ex_Ret_Var =MKTRF SMB HML UMD;
run;

proc reg data= Return_Data plots=none;
model &Ex_Ret_Var =MKTRF SMB HML UMD PS_VWF;
run;

proc reg data= Return_Data plots=none;
model &Ex_Ret_Var =MKTRF SMB HML UMD PS_VWF ST_Rev;
run;

proc reg data= Return_Data plots=none;
model &Ex_Ret_Var =MKTRF SMB HML UMD PS_VWF ST_Rev LT_Rev;
run;

proc delete data= Return_Data ; run;

%mend DGTW_Ret_and_Alphas;




*** Table 4 ***;


** Panel A **;

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_1_2_3, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_5, Ex_Ret_Var=TP_ex_ret_Ex_5)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_1_2_3, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_5, Ex_Ret_Var=Rec_ex_ret_Ex_5)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_1_2_3, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_5, Ex_Ret_Var=TP_Rec_diff_ret_Ex_5)

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_4_5_6, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_10, Ex_Ret_Var=TP_ex_ret_Ex_10)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_4_5_6, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_10, Ex_Ret_Var=Rec_ex_ret_Ex_10)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_4_5_6, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_10, Ex_Ret_Var=TP_Rec_diff_ret_Ex_10)

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_7_8_9, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_20, Ex_Ret_Var=TP_ex_ret_Ex_20)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_7_8_9, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_20, Ex_Ret_Var=Rec_ex_ret_Ex_20)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_A_Column_7_8_9, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_20, Ex_Ret_Var=TP_Rec_diff_ret_Ex_20)


** Panel B **;

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_1_2_3, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_5, Ex_Ret_Var=TP_ex_ret_Ex_5)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_1_2_3, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_5, Ex_Ret_Var=Rec_ex_ret_Ex_5)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_1_2_3, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_5, Ex_Ret_Var=TP_Rec_diff_ret_Ex_5)

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_4_5_6, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_10, Ex_Ret_Var=TP_ex_ret_Ex_10)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_4_5_6, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_10, Ex_Ret_Var=Rec_ex_ret_Ex_10)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_4_5_6, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_10, Ex_Ret_Var=TP_Rec_diff_ret_Ex_10)

%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_7_8_9, DGTW_Ret_Var=TP_DGTW_adj_ret_Ex_20, Ex_Ret_Var=TP_ex_ret_Ex_20)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_7_8_9, DGTW_Ret_Var=Rec_DGTW_adj_ret_Ex_20, Ex_Ret_Var=Rec_ex_ret_Ex_20)
%DGTW_Ret_and_Alphas(Dataset=TP_Data.Table_4_Panel_B_Column_7_8_9, DGTW_Ret_Var=TP_Rec_dif_DGTW_adj_ret_Ex_20, Ex_Ret_Var=TP_Rec_diff_ret_Ex_20)


